{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 用户对某个事件是否感兴趣\n",
    "\n",
    "### 活动描述信息在events.csv文件：共110维特征\n",
    "前9列：event_id, user_id, start_time, city, state, zip, country, lat, and lng.\n",
    "1. event_id：活动的id, \n",
    "2. user_id：创建活动的用户的id .  \n",
    "3. city, state, zip, and country： 活动地点 (如果知道的话).\n",
    "4. lat and lng： floats（活动地点的经度和纬度）\n",
    "5. start_time： 字符串，ISO-8601 UTC time，表示活动开始时间\n",
    "\n",
    "后101列为词频：count_1, count_2, ..., count_100，count_other\n",
    "1. count_N：活动描述出现第N个词的次数\n",
    "2. count_other：除了最常用的100个词之外的其余词出现的次数\n",
    "\n",
    "### 作业要求：\n",
    "1. 根据活动的关键词（count_1, count_2, ..., count_100，count_other属性）做聚类，可采用KMeans聚类\n",
    "2. 尝试K=10，20，30，..., 100, 并计算各自CH_scores。\n",
    "\n",
    "### 提示：\n",
    "\n",
    "由于样本数目较多，建议使用MiniBatchKMeans。\n",
    "\n",
    "### 文件说明：\n",
    "1. 可以先运行0. EDA.ipynb，看一下竞赛所有数据的情况；\n",
    "2. 总体活动的数目太多（300w+记录），可以只需对训练集train.csv和测试集test.cv出现的活动（13418条记录）举行聚类即可。运行1. Users_Events.ipynb可得到只在训练集train.csv和测试集test.cv出现的活动，可自己修改代码存为csv格式，在进行聚类。\n",
    "\n",
    "### 批改标准 \n",
    "1. 抽取出只在训练集和测试集中出现的event：20分\n",
    "2. 聚类 ：40分\n",
    "3. CH_scores计算：20分\n",
    "4. 结果显示/分析：20分"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1、抽取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import scipy.io as sio # 读取文件\n",
    "\n",
    "from collections import defaultdict # 集合\n",
    "\n",
    "import csv # csv写文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of uniqueUsers :3391\n",
      "number of uniqueEvents :13418\n"
     ]
    }
   ],
   "source": [
    "# 统计训练集和测试集中出现的活动、用户\n",
    "uniqueEvents = set()\n",
    "uniqueUsers = set()\n",
    "\n",
    "# 文件路径\n",
    "fpath = \"./courseware_code/\"\n",
    "\n",
    "for filename in [\"train.csv\",\"test.csv\"]:\n",
    "    f = open(fpath + filename,'rb')\n",
    "    \n",
    "    #忽略第一行（列名字）\n",
    "    f.readline().strip().split(\",\")\n",
    "    \n",
    "    for line in f: # 读取每条记录\n",
    "        cols = line.strip().split(\",\")\n",
    "        uniqueUsers.add(cols[0])  # 第一列为用户ID\n",
    "        uniqueEvents.add(cols[1]) # 第二列为活动ID\n",
    "    f.close()\n",
    "\n",
    "n_uniqueUsers = len(uniqueUsers)\n",
    "n_uniqueEvents = len(uniqueEvents)\n",
    "\n",
    "print(\"number of uniqueUsers :%d\" % n_uniqueUsers)\n",
    "print(\"number of uniqueEvents :%d\" % n_uniqueEvents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "import scipy.sparse as ss\n",
    "# 用户与事件关系矩阵表，记录用户对活动感兴趣，作为events.csv提取数据后标签y值\n",
    "userEventScores = ss.dok_matrix((n_uniqueUsers,n_uniqueEvents))\n",
    "\n",
    "# 对活动重建索引字典，以便后续用于判断events.csv中事件是否存在于uniqueEvents中\n",
    "userIndex = dict()\n",
    "eventIndex = dict()\n",
    "\n",
    "eventScore = dict() # 感兴趣的事件活动标识，userEventScores矩阵与用户有关，但题目只分析词频特征的聚类\n",
    "\n",
    "# 重新编码用户索引字典\n",
    "for i,u in enumerate(uniqueUsers):\n",
    "    userIndex[u] = i\n",
    "\n",
    "# 重新编码活动索引字典\n",
    "for i,e in enumerate(uniqueEvents):\n",
    "    eventIndex[e] = i\n",
    "    \n",
    "ftrain = open(fpath + \"train.csv\",\"rb\")\n",
    "ftrain.readline()\n",
    "for line in ftrain:\n",
    "    cols = line.strip().split(\",\")\n",
    "    i = userIndex[cols[0]]  # 用户\n",
    "    j = eventIndex[cols[1]] # 活动\n",
    "    \n",
    "    score = int(cols[4])\n",
    "    userEventScores[i,j] = score\n",
    "    \n",
    "    eventScore[cols[1]] = score\n",
    "    \n",
    "ftrain.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "#fwname = \"events_train.csv\"\n",
    "fwname = \"events_min2.csv\"\n",
    "if os.path.exists(fwname) == True:\n",
    "    os.remove(fwname)\n",
    "\n",
    "# 准备要写入的文件\n",
    "fw = open(fwname,'wb')\n",
    "writer = csv.writer(fw) # 获取输出数据流\n",
    "\n",
    "# 读取events.csv文件，抽取与集合uniqueEvents中有关的事件数据\n",
    "fe = open(fpath + \"events.csv\",'rb')\n",
    "cols = fe.readline().strip().split(\",\")\n",
    "cols.append(\"interest\")\n",
    "# print(cols)\n",
    "writer.writerow(cols)\n",
    "\n",
    "for line in fe: # 读取每条记录\n",
    "    cols = line.strip().split(\",\")\n",
    "    # if cols[0] in eventIndex and cols[1] in userIndex: # 存在，则写入events_tain.csv文件中\n",
    "    #     cols.append(userEventScores[userIndex[cols[1]],eventIndex[cols[0]]])\n",
    "    if cols[0] in eventIndex: # 存在，则写入events_min.csv文件中\n",
    "        if cols[0] in eventScore:\n",
    "            cols.append(str(eventScore[cols[0]]))\n",
    "        else:\n",
    "            cols.append(\"0\")\n",
    "        writer.writerow(cols)\n",
    "\n",
    "fw.close()\n",
    "fe.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2、聚类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import metrics\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "import time\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 读取训练数据\n",
    "train = pd.read_csv(fwname) # \"events_min.csv\"\n",
    "\n",
    "y_train = train[\"interest\"].values\n",
    "dropField = [\"event_id\",\"user_id\",\"start_time\",\"city\",\"state\",\"zip\",\"country\",\"lat\",\"lng\",\"interest\"]\n",
    "X_train = train.drop(dropField,axis=1).values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the shape of train: (13418L, 101L)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(13418L, 101L)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 原始输入的特征维数和样本数目\n",
    "print('the shape of train: {}'.format(X_train.shape))\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n# \\xe5\\xaf\\xb9\\xe6\\x95\\xb0\\xe6\\x8d\\xae\\xe8\\xbf\\x9b\\xe8\\xa1\\x8cPCA\\xe9\\x99\\x8d\\xe7\\xbb\\xb4\\npca = PCA(n_components = 0.75)\\npca.fit(X_train)\\n\\nX_train_pca = pca.transform(X_train)\\n\\n# \\xe9\\x99\\x8d\\xe7\\xbb\\xb4\\xe5\\x90\\x8e\\xe7\\x9a\\x84\\xe7\\x89\\xb9\\xe5\\xbe\\x81\\xe7\\xbb\\xb4\\xe6\\x95\\xb0\\nprint(X_train_pca.shape)\\n\\n(13418L, 1L) # \\xe4\\xb8\\x8d\\xe9\\x80\\x82\\xe5\\x90\\x88\\xef\\xbc\\x9f\\n\\n'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"\n",
    "# 对数据进行PCA降维\n",
    "pca = PCA(n_components = 0.75)\n",
    "pca.fit(X_train)\n",
    "\n",
    "X_train_pca = pca.transform(X_train)\n",
    "\n",
    "# 降维后的特征维数\n",
    "print(X_train_pca.shape)\n",
    "\n",
    "(13418L, 1L) # 不适合？\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将训练集合拆分成训练集和校验集，在校验集上找到最佳的模型超参数\n",
    "X_train_part,X_val,y_train_part,y_val = train_test_split(X_train,y_train,train_size=0.8,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10734L, 101L)\n",
      "(2684L, 101L)\n"
     ]
    }
   ],
   "source": [
    "# 拆分后的训练集和校验集的样本数目\n",
    "print(X_train_part.shape)\n",
    "print(X_val.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 一个参数点（聚类数据为K）的模型，在校验集上评价聚类算法性能\n",
    "def K_cluster_analysis(K,X_train,y_train,X_val,y_val):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters:{}\".format(K));\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    mb_kmeans = MiniBatchKMeans(n_clusters=K)\n",
    "    mb_kmeans.fit(X_train)\n",
    "    \n",
    "    # 在测试集上测试\n",
    "    y_val_pred = mb_kmeans.predict(X_val)\n",
    "    \n",
    "    # K值的评估标准\n",
    "    # 常见的方法有轮廓系数Silhouette Coefficient 和 Calinski-Harbasz Index\n",
    "    # 这两个分值越大则聚类效果越好\n",
    "    CH_score = metrics.silhouette_score(X_train,mb_kmeans.predict(X_train))\n",
    "    \n",
    "    end = time.time()\n",
    "    print(\"CH_score:{},time elaps:{}\".format(CH_score,int(end-start)))\n",
    "    \n",
    "    return CH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters:10\n",
      "CH_score:0.444135838312,time elaps:6\n",
      "K-means begin with clusters:20\n",
      "CH_score:0.219851430857,time elaps:6\n",
      "K-means begin with clusters:30\n",
      "CH_score:0.183843806677,time elaps:6\n",
      "K-means begin with clusters:40\n",
      "CH_score:0.16410588746,time elaps:5\n",
      "K-means begin with clusters:50\n",
      "CH_score:0.127208931155,time elaps:5\n",
      "K-means begin with clusters:60\n",
      "CH_score:0.100863484036,time elaps:5\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = [10,20,30,40,50,60]\n",
    "CH_scores = []\n",
    "\n",
    "for K in Ks:\n",
    "    ch = K_cluster_analysis(K,X_train_part,y_train_part,X_val,y_val)\n",
    "    CH_scores.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x36e00160>]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl4VdW5x/HvSxiUSaZAlcGgooJT0APV62xF0SrQqhWsLXq9olWcEDXcettbvK0zaitaqFZrW0VQqzhrraBWRYJGEBAZxJJGBQRnZPK9f6wdc4KBHMhJds4+v8/znCfZ++x9zrse8bd29rCWuTsiIpIfmsRdgIiINByFvohIHlHoi4jkEY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qP+h7v/mIS2t5KZtTKzNpW/E+bTfouE/tt29w+AZWa2R7Tqe8A8GqC9OftwlpndBxxBGJXuQ+CXwMPAZKAH8C/gFE/QnLxmdgjwIjCHqvO9/004r5/IdpvZvsCfgALCQcpkdx9rZrsQjoQ7AG8Ap7v72vgqzT4zOwIY7e4nJL29Ufv+Fi02Be5191+bWUeS+2+7GLgDaA4sAc4k+jdOPbY3Z0NfRES2XtJO74iIyBYo9EVE8ohCX0Qkjyj0RUTyiEJfRCSPKPRFRPKIQl9EJI8o9EVE8sj/A7CCXRkVGHkbAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x36f638d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制不同K值下的模型性能，找到最佳模型/参数（分数最高）\n",
    "plt.plot(Ks,np.array(CH_scores),'r-')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论分析：以上图可以看出，最好模型的K值是<=10，所以 0< K <=10 范围内继续调参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters:2\n",
      "CH_score:0.811792543504,time elaps:6\n",
      "K-means begin with clusters:3\n",
      "CH_score:0.610618927283,time elaps:6\n",
      "K-means begin with clusters:4\n",
      "CH_score:0.414014351616,time elaps:6\n",
      "K-means begin with clusters:5\n",
      "CH_score:0.439272299087,time elaps:6\n",
      "K-means begin with clusters:6\n",
      "CH_score:0.400454811165,time elaps:6\n",
      "K-means begin with clusters:7\n",
      "CH_score:0.463457388311,time elaps:6\n",
      "K-means begin with clusters:8\n",
      "CH_score:0.436898191186,time elaps:6\n",
      "K-means begin with clusters:9\n",
      "CH_score:0.439531589977,time elaps:6\n",
      "K-means begin with clusters:10\n",
      "CH_score:0.427618674078,time elaps:6\n"
     ]
    }
   ],
   "source": [
    "# 二次调参\n",
    "Ks = [2,3,4,5,6,7,8,9,10]\n",
    "CH_scores = []\n",
    "\n",
    "for K in Ks:\n",
    "    ch = K_cluster_analysis(K,X_train_part,y_train_part,X_val,y_val)\n",
    "    CH_scores.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x21ddbcf8>]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8leWd9/HPLwmByI4gyg6yhIAsSaBFCi1qFYQCCYvggiAJ6VPbOqOPT+1UnI6d6diZ1o61VGQRpLgQgSgoRZm6VYtAwiZhDZtABMK+hmzX80ciDWtO4CT3Wb7v1yuvk3Ny5dxf8jp8c+e67vvc5pxDRERCS4TXAURExP9U7iIiIUjlLiISglTuIiIhSOUuIhKCVO4iIiFI5S4iEoJU7iIiIUjlLiISgqK82nDjxo1dmzZtvNq8iEhQysrKOuSca1LROM/KvU2bNmRmZnq1eRGRoGRmu30Zp2kZEZEQpHIXEQlBKncRkRCkchcRCUEqdxGREKRyFxEJQSp3EZEQFHTlvnLfSn7+vz/3OoaISEALunLPzM3kuc+fIys3y+soIiIBK+jK/f7b7icmKobpq6d7HUVEJGD5VO5mNtDMtphZjpk9dZmvtzKzj8xsjZmtN7N7/R+1VINaDRjVZRSvf/k6pwtOV9VmRESCWoXlbmaRwBRgEBAHjDWzuIuGPQ2kO+d6AmOAP/k7aHmp8amcLDhJenZ6VW5GRCRo+bLn3hvIcc7tcM4VAG8Cwy4a44B6ZZ/XB3L9F/FSfVv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5WNmf8R9z6TybF/oCQ81sF/AmcIeZzfU2UinnXG7Z7UFK5497e5sIgL3A3nJ/dc2ntOwDxSBgtXPugNdBytwF7HTO5TnnCoGFwO0eZwLAOTfTORfvnOtP6bTINq8zlXPAzG4BKLs9WBUbCapyNzOjdD50k3Puea/zfMPMmphZg7LPYyh90W/2NhU4537unGtRduHyMcCHzjnP96zMrLaZ1f3mc+BuSv+U9pRzbj+wx8w6lT10J7DRw0gXG0uATMmU+Qr4tpndUPZ/804CYAEawMxuKrttBSQTWD+3RcDDZZ8/DLxTFRvx6RqqAaQv8BDwZdn8NsC/lF3j1Uu3AK+aWSSlvzDTnXMBc9hhAGoKZJT2AVHA6865pd5GOu8nwGtlUyA7gAke5wGgbO74+0Ca11m+4ZxbYWbzgdWUTnusIXDOCF1gZjcChcCjzrmjXoQwszeA7wGNzWwv8K/Ac0C6mU2k9BfkqCrZts5QFREJPUE1LSMiIr5RuYuIhCCVu4hICFK5i4iEIJW7iEgIUrmLiIQglbuISAhSuYuIhKD/DzTnmcKnJH2jAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x216979b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制不同K值下的模型性能，找到最佳模型/参数（分数最高）\n",
    "plt.plot(Ks,np.array(CH_scores),'g-')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：K=2时，模型最佳，这也符合“是否兴趣”这样两类分问题的预期。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3、结果显示分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJza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sAYoD+hyqOtSv3tO6LT/xd6egBYC4wIvRvpAAABcElEQVRPvR8HvNFFadkmzKyWcPO/y90XRpvXxUW9aLm+q9JXZgcDJ5jZq4TqvsmEEsGgqFoAKvvfwFpgrbs/Hr2/hxAQsvD7TwFWuXujuzcDC4GDyM5vn5bv9+70/bCnB4C/ArtGPQF6ERqFFndxmsomqu++DVju7jek/rQYmBGtzwAWbeu0bQvufqm7j3P3HQm/9UPufjrwJ+CUaLdKvv43gTVmNjHadCTwPNn4/VcDB5hZv+j/QXztmfjt28j3ey8Gzoh6Ax0AvBtXFeXl7j36BRwLvAS8Alze1ekp87UeQijSPQM8Hb2OJdSDLwFejpZDujqt2+C7OBy4L1rfGXgCWAHMB3p3dfrKeN17AfXRv4F7gcFZ+f2Bq4EXgGXAnUDvSv/tgbsJbR7NhBz+Wfl+b0IV0NzoXvgsocdUu5+vqSBERDKqp1cBiYhIgRQAREQySgFARCSjFABERDJKAUBEJKMUAEREMkoBQEQko/4P1cZ1gIRmCC8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1f478ef0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 显示聚类结果\n",
    "# 画出聚类结果，没一类用一种颜色\n",
    "colors=['r','g']\n",
    "\n",
    "n_clusters=2\n",
    "mb_kmeans = MiniBatchKMeans(n_clusters = n_clusters)\n",
    "mb_kmeans.fit(X_train)\n",
    "\n",
    "y_train_pred = mb_kmeans.labels_\n",
    "cents = mb_kmeans.cluster_centers_ # 质心\n",
    "\n",
    "for i in range(n_clusters):\n",
    "    index = np.nonzero(y_train_pred ==i)[0]\n",
    "    x1 = X_train[index,0]\n",
    "    x2 = X_train[index,1]\n",
    "    y_i = y_train[index]\n",
    "    \n",
    "    for j in range(len(x1)):\n",
    "        if j < 1000:\n",
    "            plt.text(x1[j],x2[j],str(int(y_i[j])),color=colors[i],fontdict={'weight':'bold','size':9})\n",
    "        \n",
    "plt.axis([-5,100,-6,100])\n",
    "plt.show()\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
